package com.horoscope.astrology.zodiac.signs.free.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.horoscope.astrology.zodiac.signs.free.R

/**
 *  作者    1024
 *  时间    2019-12-24 18:05
 *  文件    CharacterSixAdapter
 *  描述    标准Kotlin用法
 */
class CharacterSixAdapter(
    private val context: Context,
    private val mBean: ArrayList<String>
) :
    RecyclerView.Adapter<CharacterSixAdapter.ViewHolder>() {


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        return ViewHolder(
            LayoutInflater.from(context).inflate(R.layout.item_character_six, parent, false)
        )
    }

    override fun getItemCount(): Int {
        return mBean.size
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        if (mBean.size > 0) {
            when (position) {
                0 -> {
                    holder.titleUp.text = "Symbol"
                    holder.titleDown.text = mBean[0]
                }
                1 -> {
                    holder.titleUp.text = "Color"
                    holder.titleDown.text = mBean[1]
                }
                2 -> {
                    holder.titleUp.text = "Element"
                    holder.titleDown.text = mBean[2]
                }
                3 -> {
                    holder.titleUp.text = "Duality"
                    holder.titleDown.text = mBean[3]
                }
                4 -> {
                    holder.titleUp.text = "Quality"
                    holder.titleDown.text = mBean[4]
                }
                5 -> {
                    holder.titleUp.text = "Most Compatible With"
                    holder.titleDown.text = mBean[5]
                }

            }

        }
    }

    class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val titleUp: TextView = itemView.findViewById(R.id.tv_up)
        val titleDown: TextView = itemView.findViewById(R.id.tv_down)

        // Define click listener for the ViewHolder's View.
        // v.setOnClickListener { Log.d(TAG, "Element $adapterPosition clicked.") }
    }


}